{{extend 'layout.html'}}

	<script type="text/javascript" src="../../static/js/jquery-swapsies.js"></script>	
	<script>
		/*function swappen(who,target,link){
			event.preventDefault();

			$.ajax({
				  url: link,
				  success: function(data) {
						$(who).swap({
							target: target,
							opacity: "0.5",
							speed: 200,
							callback: function() {
							}
						});
				  }
				});
		}*/
	</script>


<h1>{{=page.title}}</h1>
{{=button(T('view live version'),'show',page.id)}}
{{=button(T('edit page title'),'edit',page.id)}}
{{=button(T('move page'),'movePage',page.id)}}
{{=BR()}}

{{for i in range(0,len(page_items)):}}	
	{{if page_items[i].tablename=="page_text":}}
		<div class="pageText" id="{{=page_items[i].order_nr}}">
		{{if content[i].title:}} 
			{{=H2(content[i].title)}}
		{{pass}}
		{{if content[i].type=="html":}}
			{{=XML(content[i].body)}}
			{{=button(T('edit'),'editHtml',(page.id,content[i].id))}}						
		{{elif content[i].type=="markmin":}}
			{{=MARKMIN(content[i].body, extra={'space':lambda code: '<br>'})}}
			{{=button(T('edit'),'editMarkmin',(page.id,content[i].id))}}
		{{else:}}
			{{=content[i].body}}
			{{=button(T('edit'),'editText',(page.id,content[i].id))}}
		{{pass}}
		{{=button(T('delete'),'deletePageItem',(page.id,page_items[i].id))}}
		
		<!-- start switchen van position -->
		[<a href="#nil" onclick="jQuery('#form{{=page_items[i].id}}').slideToggle();">{{=T('change order')}}</a>]
			<div id="form{{=page_items[i].id}}" style="display:none">
				{{for page_item in page_items:}}
					{{if page_item.id != page_items[i].id:}}
						{{=button(T(str(page_item.order_nr)),'sortOrderNr',(page.id,page_items[i].id,page_item.order_nr))}}
					{{pass}}			
				{{pass}}
				{{=button(T('reset order_nrs'),'resetOrderNr',(page.id))}}
			</div>	
		<!-- eind switchen van position -->		
		
		</div>
	{{elif page_items[i].tablename=="page_image":}}		
		<div class="pageImage">
			<div>
		{{if content[i].hasLightbox:}}		
			<a href="{{=URL('download',args=content[i].image)}}" rel="pageImage" title="{{=content[i].title}}">
		{{pass}}  
		<img class="pageImage" src="{{=URL('download',args=content[i].image)}}" alt="{{=content[i].title}}" />
		{{if content[i].hasLightbox:}}
			</a>		
		{{pass}}
			</div>				
		{{=button(T('edit'),'editImage',(page.id,content[i].id))}}
		{{=button(T('delete'),'deletePageItem',(page.id,page_items[i].id))}}
		
		<!-- start switchen van position -->
		[<a href="#nil" onclick="jQuery('#form{{=page_items[i].id}}').slideToggle();">{{=T('change order')}}</a>]
			<div id="form{{=page_items[i].id}}" style="display:none">
				{{for page_item in page_items:}}
					{{if page_item.id != page_items[i].id:}}
						{{=button(T(str(page_item.order_nr)),'sortOrderNr',(page.id,page_items[i].id,page_item.order_nr))}}
					{{pass}}			
				{{pass}}
				{{=button(T('reset order_nrs'),'resetOrderNr',(page.id))}}
			</div>	
		<!-- eind switchen van position -->
		
		</div>	
	{{elif page_items[i].tablename=="page_file":}}
		<div class="pageFile">
		{{=A('download', _href=URL('download',args=content[i].file))}}
		{{=button(T('edit'),'editFile',(page.id,content[i].id))}}
		{{=button(T('delete'),'deletePageItem',(page.id,page_items[i].id))}}
		
		<!-- start switchen van position -->
		[<a href="#nil" onclick="jQuery('#form{{=page_items[i].id}}').slideToggle();">{{=T('change order')}}</a>]
			<div id="form{{=page_items[i].id}}" style="display:none">
				{{for page_item in page_items:}}
					{{if page_item.id != page_items[i].id:}}
						{{=button(T(str(page_item.order_nr)),'sortOrderNr',(page.id,page_items[i].id,page_item.order_nr))}}
					{{pass}}			
				{{pass}}
				{{=button(T('reset order_nrs'),'resetOrderNr',(page.id))}}
			</div>	
		<!-- eind switchen van position -->
		
		</div>
	{{elif page_items[i].tablename=="page_form":}}
		<div class="pageForm">
		{{try:}}
        	{{page_id=int(request.args(0))}}
    	{{except:}}
        	{{page=db(db.page.url==request.args(0)).select().first() or redirect(error)}}
        	{{page_id=page.id}}
        {{pass}}	
		
		{{if content[i].form_type == 'Support':}}
			{{requestForm = 'support.load'}}
			{{title = 'Vraag support aan'}}
			{{src = '../../static/images/buttonSupportt.png'}}
			<a href="{{=URL('contact',requestForm,args=[page_id])}}" rel="iframe" title="{{=title}}">
			<img href="" src="{{=src}}"/>
			<a><br>		
		{{elif content[i].form_type == 'Demo':}}
			{{requestForm = 'demo.load'}}
			{{title = 'Vraag een demo aan'}}
			{{src = '../../static/images/buttonDemo.png'}}
			<a href="{{=URL('contact',requestForm,args=[page_id])}}" rel="iframe" title="{{=title}}">
			<img href="" src="{{=src}}"/>
			<a><br>		
		{{elif content[i].form_type == 'Offers':}}
			{{requestForm = 'offers.load'}}
			{{title = 'Vraag een offerte aan'}}
			{{src = '../../static/images/buttonOfferte.png'}}
			<a href="{{=URL('contact',requestForm,args=[page_id])}}" rel="iframe" title="{{=title}}">
			<img href="" src="{{=src}}"/>
			<a><br>		
		{{elif content[i].form_type == 'Question':}}
			{{requestForm = 'question.load'}}
			{{title = 'Stel ons een vraag'}}
			{{src = '../../static/images/buttonQuestion.png'}}
			<a href="{{=URL('contact',requestForm,args=[page_id])}}" rel="iframe" title="{{=title}}">
			<img href="" src="{{=src}}"/>
			<a><br>		
		{{else:}}
			{{=LOAD('contact','contact.load',ajax=True)}}
		{{pass}}
		
		{{=button(T('edit'),'editForm',(page.id,content[i].id))}}
		{{=button(T('delete'),'deletePageItem',(page.id,page_items[i].id))}}
	
		<!-- start switchen van position -->
		[<a href="#nil" onclick="jQuery('#form{{=page_items[i].id}}').slideToggle();">{{=T('change order')}}</a>]
			<div id="form{{=page_items[i].id}}" style="display:none">
				{{for page_item in page_items:}}
					{{if page_item.id != page_items[i].id:}}
						{{=button(T(str(page_item.order_nr)),'sortOrderNr',(page.id,page_items[i].id,page_item.order_nr))}}
					{{pass}}			
				{{pass}}
				{{=button(T('reset order_nrs'),'resetOrderNr',(page.id))}}
			</div>	
		<!-- eind switchen van position -->
		
		</div>		
	{{elif page_items[i].tablename=="page_link":}}
		<div class="pageLink">
		{{=A(content[i].title, _href=content[i].link)}}
		{{=button(T('edit'),'editLink',(page.id,content[i].id))}}
		{{=button(T('delete'),'deletePageItem',(page.id,page_items[i].id))}}
		
		<!-- start switchen van position -->
		[<a href="#nil" onclick="jQuery('#form{{=page_items[i].id}}').slideToggle();">{{=T('change order')}}</a>]
			<div id="form{{=page_items[i].id}}" style="display:none">
				{{for page_item in page_items:}}
					{{if page_item.id != page_items[i].id:}}
						{{=button(T(str(page_item.order_nr)),'sortOrderNr',(page.id,page_items[i].id,page_item.order_nr))}}
					{{pass}}			
				{{pass}}
				{{=button(T('reset order_nrs'),'resetOrderNr',(page.id))}}
			</div>	
		<!-- eind switchen van position -->
		</div>
	{{elif page_items[i].tablename=="page_faq":}}
		<div class="pageFAQ">
		Q: {{= content[i].question }} <br>
		A: {{= content[i].answer }}
		{{=button(T('edit'),'editLink',(page.id,content[i].id))}}
		{{=button(T('delete'),'deletePageItem',(page.id,page_items[i].id))}}
		
		<!-- start switchen van position -->
		[<a href="#nil" onclick="jQuery('#form{{=page_items[i].id}}').slideToggle();">{{=T('change order')}}</a>]
			<div id="form{{=page_items[i].id}}" style="display:none">
				{{for page_item in page_items:}}
					{{if page_item.id != page_items[i].id:}}
						{{=button(T(str(page_item.order_nr)),'sortOrderNr',(page.id,page_items[i].id,page_item.order_nr))}}
					{{pass}}			
				{{pass}}
				{{=button(T('reset order_nrs'),'resetOrderNr',(page.id))}}
			</div>	
		<!-- eind switchen van position -->
		</div>
	{{elif page_items[i].tablename=="page_picasa":}}
		<div class="pagePicasa">
		<strong>Google Picasa</strong><br>
		UserID={{=content[i].userid}}<br>
		AlbumID={{=content[i].albumid}}<br>
		{{=button(T('edit'),'editPicasa',(page.id,content[i].id))}}						
		{{=button(T('delete'),'deletePageItem',(page.id,page_items[i].id))}}
		
		<!-- switchen van position -->
		[<a href="#nil" onclick="jQuery('#form{{=page_items[i].id}}').slideToggle();">{{=T('change order')}}</a>]
			<div id="form{{=page_items[i].id}}" style="display:none">
				{{for page_item in page_items:}}
					{{if page_item.id != page_items[i].id:}}
						{{=button(T(str(page_item.order_nr)),'sortOrderNr',(page.id,page_items[i].id,page_item.order_nr))}}
					{{pass}}			
				{{pass}}
				{{=button(T('reset order_nrs'),'resetOrderNr',(page.id))}}
			</div>	
		</div>
	{{elif page_items[i].tablename=="page_youtube":}}
		<div class="pageYoutube">
		<iframe width="640" height="480" src="http://www.youtube.com/embed/{{=content[i].youtube}}?rel=0" frameborder="0" allowfullscreen></iframe>
		{{=button(T('edit'),'editYoutube',(page.id,content[i].id))}}						
		{{=button(T('delete'),'deletePageItem',(page.id,page_items[i].id))}}
		
		<!-- switchen van position -->
		[<a href="#nil" onclick="jQuery('#form{{=page_items[i].id}}').slideToggle();">{{=T('change order')}}</a>]
			<div id="form{{=page_items[i].id}}" style="display:none">
				{{for page_item in page_items:}}
					{{if page_item.id != page_items[i].id:}}
						{{=button(T(str(page_item.order_nr)),'sortOrderNr',(page.id,page_items[i].id,page_item.order_nr))}}
					{{pass}}			
				{{pass}}
				{{=button(T('reset order_nrs'),'resetOrderNr',(page.id))}}
			</div>	
		</div>
	{{elif page_items[i].tablename=="page_slider":}}
        <div class="slider-wrapper theme-default" style="width: {{=content[i].width}}px !important;">
            <div id="slider_{{=content[i].id}}" class="nivoSlider">
			{{for x in ('image1','image2', 'image3', 'image4', 'image5', 'image6', 'image7', 'image8', 'image9', 'image10'):}}
				{{if content[i][x]:}}
				<img src="{{=URL('download',args=content[i][x])}}" alt="" style="max-width: {{=content[i].width}}px !important; max-height: {{=content[i].height}}px !important;"/>
                {{pass}}
            {{pass}}
            </div>
        </div>
    <script type="text/javascript" src="{{=URL('static','js/nivoslider/jquery.nivo.slider.js')}}"></script>
    <script type="text/javascript">
    $(window).load(function() {
        $('#slider_{{=content[i].id}}').nivoSlider();
    });
    </script>
	{{=button(T('edit'),'editSlider',(page.id,content[i].id))}}
	{{=button(T('delete'),'deletePageItem',(page.id,page_items[i].id))}}
		
		<!-- start switchen van position -->
		[<a href="#nil" onclick="jQuery('#form{{=page_items[i].id}}').slideToggle();">{{=T('change order')}}</a>]
		<div id="form{{=page_items[i].id}}" style="display:none">
			{{for page_item in page_items:}}
				{{if page_item.id != page_items[i].id:}}
					{{=button(T(str(page_item.order_nr)),'sortOrderNr',(page.id,page_items[i].id,page_item.order_nr))}}
				{{pass}}			
			{{pass}}
			{{=button(T('reset order_nrs'),'resetOrderNr',(page.id))}}
		</div>	
		<!-- eind switchen van position -->
	{{pass}}
{{pass}}



{{=BR()}}
[<a href="#nil" onclick="jQuery('#form_text').slideToggle();">{{=T('+ text')}}</a>]
<div id="form_text" style="display:none">
	<h3>{{=T("Choose text format")}}</h3>
	<div class="pageLink">{{=A('html', _href=URL('editHtml',args=(page.id,0)))}}</div>
	<div class="pageLink">{{=A('markmin', _href=URL('editMarkmin',args=(page.id,0)))}}</div>
	<div class="pageLink">{{=A('plain', _href=URL('editText',args=(page.id,0)))}}</div>
</div>
{{=button(T('+ image'),'editImage',(page.id,0))}}
{{=button(T('+ file'),'editFile',(page.id,0))}}
{{=button(T('+ link'),'editLink',(page.id,0))}}
{{=button(T('+ faq'),'editFAQ',(page.id,0))}}
{{=button(T('+ picasa'),'editPicasa',(page.id,0))}}
{{=button(T('+ youtube'),'editYoutube',(page.id,0))}}
{{=button(T('+ imageSlider'),'editSlider',(page.id,0))}}
{{=button(T('+ form'),'editForm',(page.id,0))}}

{{if page_children:}}
<div class="pageSubmenu">
{{=SPAN(H2(T('Sub pages')))}}
{{if page.childrenTitle:}}{{=H3(page.childrenTitle)}}{{pass}}
<ul>
	{{for child in page_children:}}
		<li>{{=A(child.title,_href=URL('show/%s' % child.url))}}</li>
	{{pass}}
</ul>
</div>
{{pass}}

[<a href="#nil" onclick="jQuery('#form').slideToggle();">{{=T('+ page')}}</a>]
<div id="form" style="display:none">
<h3>{{=T("Add sub page")}}</h3>
{{=form}}
</div>

<script type="text/javascript">
$(document).ready(function() {
    $("a[rel=iframe]").fancybox({
        'type': 'iframe',
        'width': 600,
        'height': 450,
        'scrolling': 'auto',
        'autoDimensions': true,
        'showNavArrows': false,
        'hideOnOverlayClick': true,
        'transitionIn'  :   'elastic',
        'transitionOut' :   'elastic',
        'overlayColor' :    '#FFFFFF'
    });
});
</script>

